window.onload = function () {
    $(document).scroll()
}

$(function () {
    $(document).on('scroll', function () {
        if ($(document).scrollTop() < 400) {
            $('.viceNav').hide();
        } else {
            $('.viceNav').show();
        }
    })
})

var bannerSwiper = new Swiper('#bannerSwiper', {
    autoplay: 3000, //可选选项，自动滑动
    loop: true,
    pagination: '.swiper-pagination',
    paginationClickable: true,
    prevButton: '.swiper-button-prev',
    nextButton: '.swiper-button-next',
})
//鼠标进入停止自动切换
bannerSwiper.container[0].onmouseover = function () {
    bannerSwiper.stopAutoplay();
}
//鼠标离开开始自动切换
bannerSwiper.container[0].onmouseout = function () {
    bannerSwiper.startAutoplay();
}

var newsSwiper = new Swiper('#newsSwiper', {
    speed: 2000, //匀速时间
    autoplay: {
        delay: 0,
        stopOnLastSlide: false,
        disableOnInteraction: true,
    },
    loop: true,
    direction: 'vertical',
})

var actSwiper = new Swiper('.swiper-container.act', {
    autoplay: 3000,
    loop: true,
    pagination: '.swiper-pagination',
    paginationClickable: true,
})

$(function () {
    $('#actSwiper .arrow-left').click(function () {
        actSwiper.slidePrev();
    })
    $('#actSwiper .arrow-right').click(function () {
        actSwiper.slideNext();
    })
})


var newProSwiper = new Swiper('.swiper-container.newPro', {
    slidesPerView: 'auto',
    centeredSlides: true,
    pagination: '.swiper-pagination',
    paginationClickable: true,
    onSlideChangeStart() {
        if (newProSwiper.activeIndex == 0) {
            $('#newProSwiper .arrow-left').hide();
            $('#newProSwiper .back-left').hide();
            $('#newProSwiper .arrow-right').show();
            $('#newProSwiper .back-right').show();
        } else if (newProSwiper.activeIndex == 1) {
            $('#newProSwiper .arrow-right').hide();
            $('#newProSwiper .back-right').hide();
            $('#newProSwiper .arrow-left').show();
            $('#newProSwiper .back-left').show();
        }
    }
})
$('#newProSwiper .arrow-right').click(function () {
    newProSwiper.slideTo(1);
})
$('#newProSwiper .arrow-left').click(function () {
    newProSwiper.slideTo(0);
})

$(function () {
    $('#elevator .menu-item').click(function () {
        // 页面平滑的滚动到相应的位置
        scrollToTop($("." + $(this).attr("id")).offset().top - 64)
    })
    $('#elevator .toTop').click(function() {
        scrollToTop(0)
    })
    $('.backtohead').click(function() {
        scrollToTop(0)
    })
    /* 监听滚动 */
    $(document).scroll(function () {
        var top = $(document).scrollTop(); //滚动条距离顶部的高度
        if ($('#elevator').css('display') === 'none' && $('.elevator-item').eq(0).offset().top - 200 <= top) {
            $('#elevator').css('display', 'block')
        } else if ($('.elevator-item').eq(0).offset().top - 200 > top) {
            $('#elevator').css('display', 'none')
        }

        // if ($('#elevator').css('display')==='none' && $('.elevator-item').eq(0).offset().top - 500 <= top) {
        //     $('#elevator').css('display', block)
        // }

        if ($(document).height() <= (parseInt($(document).scrollTop() + 1) + $(window).height())) { //滚动条滑到底部啦
            $("#elevator .menu-item").removeClass('active')
            $("#elevator .menu-item:last").addClass('active')
            return;
        }

        $(".elevator-item").each(function (i, item) {
            if ($(this).offset().top - 500 <= top) {
                $("#elevator .menu-item").removeClass('active')
                $("#" + item.classList[0]).addClass('active');
            }
        })
    });
})
/** 将滚动轴滚到相应位置 */
function scrollToTop(number) {
    window.scrollTo({
        top: number,
        behavior: "smooth"
    });
}
$(function () {
    $('.qipao-entry').hover(function () {
        $(`#${$('.qipao-entry').data('parent')} .qipao`).show();
    }, function () {
        $(`#${$('.qipao-entry').data('parent')} .qipao`).hide();
    })
})

$(function () {
    $('.bottomMain .hotpro li .more').click(function () {
        $('.bottomMain .hotpro li .hide').css('display', 'inline')
        $(this).css('display', 'none')
    })
})

